﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>    


		<head>
		<script type="text/javascript" src="<c:url value='/easyui/datagrid-detailview.js'/>"></script>
		<script type="text/javascript">
			$(function(){
				  init();
			  
			});

			function init(){
				$('#t-dg').datagrid({
				loadMsg:'',
				view:detailview,
				onDblClickRow:function(rowIndex, rowData){
					$('#t-dg').datagrid('expandRow',rowIndex);
                },
                rowStyler:function(index,row){  
			        if(row.timeout <= 0){               
			        	return 'background-color:${cfgs["expbgcolor"]};color:${cfgs["expfgcolor"]};font-weight:bold;';     
		            }   
		        },  
				detailFormatter:function(index,row){
				  var content = '';
          
          content += '<span style="color:blue;font-weight:700">方式：</span></br>';
content += '<div style="padding:5px">'+ row.op_mode.replace(/\r\n/gi,'<br/>')+'</div>';
content += '<span style="color:blue;font-weight:700">类型：</span></br>';
content += '<div style="padding:5px">'+ row.op_type.replace(/\r\n/gi,'<br/>')+'</div>';

          
          if (row.unitname)  {
   content += '<span style="color:blue;font-weight:700">单位名称：</span></br>';
   content += '<div style="padding:5px">'+ row.unitname.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.editdate)  {
   content += '<span style="color:blue;font-weight:700">录入时间：</span></br>';
   content += '<div style="padding:5px">'+ row.editdate.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.valid_time_hint)  {
   content += '<span style="color:blue;font-weight:700">过期时间：</span></br>';
   content += '<div style="padding:5px">'+ row.valid_time_hint.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.address)  {
   content += '<span style="color:blue;font-weight:700">地址：</span></br>';
   content += '<div style="padding:5px">'+ row.address.replace(/\r\n/gi,'<br/>')+'</div>';
}


if (row.mj)  {
	   content += '<span style="color:blue;font-weight:700">面积：</span></br>';
	   content += '<div style="padding:5px">'+ row.mj.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.tx)  {
	   content += '<span style="color:blue;font-weight:700">套型：</span></br>';
	   content += '<div style="padding:5px">'+ row.tx.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.lc)  {
	   content += '<span style="color:blue;font-weight:700">楼层：</span></br>';
	   content += '<div style="padding:5px">'+ row.lc.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.jg)  {
	   content += '<span style="color:blue;font-weight:700">价格：</span></br>';
	   content += '<div style="padding:5px">'+ row.jg.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.zx)  {
	   content += '<span style="color:blue;font-weight:700">装修：</span></br>';
	   content += '<div style="padding:5px">'+ row.zx.replace(/\r\n/gi,'<br/>')+'</div>';
	}
	if (row.lxfs)  {
	   content += '<span style="color:blue;font-weight:700">联系方式：</span></br>';
	   content += '<div style="padding:5px">'+ row.lxfs.replace(/\r\n/gi,'<br/>')+'</div>';
	}
if (row.context)  {
   content += '<span style="color:blue;font-weight:700">内容：</span></br>';
   content += '<div style="padding:5px">'+ row.context.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.memo)  {
   content += '<span style="color:blue;font-weight:700">备注：</span></br>';
   content += '<div style="padding:5px">'+ row.memo.replace(/\r\n/gi,'<br/>')+'</div>';
}
if (row.oper)  {
   content += '<span style="color:blue;font-weight:700">操作人员：</span></br>';
   content += '<div style="padding:5px">'+ row.oper.replace(/\r\n/gi,'<br/>')+'</div>';
}

           
					return '<div style="padding:5px">' + content + '</div>';
				}
				
			});
				
			}
			
			
			

			
			
			var actionUrl;
			function newItem(){
				$('#dlg').dialog('setTitle', '新增需求信息').dialog('open');
				$('#myform').form('clear');
				actionUrl = '<c:url value="/myinfo/Demandinfo/saveDemandinfo"/>';
			}
			
			function editItem(){
				var t = $('#t-dg');
				var row = t.datagrid('getSelected');
				if (row){
					$('#myform').form('load', row);
					$('#dlg').dialog('setTitle', '修改需求信息').dialog('open');
					actionUrl = '<c:url value="/myinfo/Demandinfo/updateDemandinfo"/>?id=' + row.id;
				}
			}
			
			
			
			
			function deleteItem(){
				var t = $('#t-dg');
				var row = t.datagrid('getSelected');
				if (row){
					$.messager.confirm('删除确认', '是否确定要删除选择需求信息?', function(r){
						if (r){
					$.ajax({
						url:'<c:url value="/myinfo/Demandinfo/destroyDemandinfo"/>?id=' + row.id,
						type:'post',
						success:function(){		
							$('#t-dg').datagrid('reload');
						}
					});
						}
						});
				}
			}
			
			function saveItem(){
				$('#myform').form('submit', {
					url:actionUrl,
					onSubmit:function(){
						return $('#myform').form('validate');
					},
					success:function(data){
						var data = eval('('+data+')');
						if (data.success){
							$('#dlg').dialog('close');
							$('#t-dg').datagrid('reload');
						} else {
							$.messager.show({
								title:'保存失败',
								msg:'<pre>'+data.msg+'</pre>'
							});
						}
					}
				});
			}
			
			function doQuery(value){
				$('#t-dg').datagrid('load', {
					q: value
				});
			}
			
		</script>
	</head>
	<body>
		<div class="easyui-layout" fit="true">
			<div region="north" border="false" style="height:40px;padding:5px;overflow:hidden;">
			<div style="padding-top:3px;float:left">
			<input class="easyui-searchbox" prompt="按地址|内容进行查询" searcher="doQuery" style="width:300px"></input>
  		</div>
		<div style="float:left">
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增需求信息</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">修改需求信息</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteItem()">删除需求信息</a>			
		</div>
	</div>
			
			
			<div region="center" border="true">
	      <table id="t-dg" style="display:none;"
						url="<c:url value='/myinfo/Demandinfo/getDemandinfoItems'/>"
						singleSelect="true" rownumbers="true" pagination="true"
						border="false" fit="true" fitColumns="true">
					<thead>
						<tr>
							<th field="unitname" width="100" sortable="true">单位名称</th>
<th field="editdate" width="100" sortable="false">录入时间</th>
<th field="op_mode" width="100" sortable="true" >方式</th>
<th field="op_type" width="100" sortable="true" >类型</th>
<th field="valid_time_hint" width="100" sortable="false">过期时间</th>
<th field="address" width="100" sortable="true">地址</th>
<th field="mj" width="100" sortable="true">面积</th>
<th field="tx" width="100" sortable="true">套型</th>
<th field="lc" width="100" sortable="true">楼层</th>
<th field="jg" width="100" sortable="true">价格</th>
<th field="zx" width="100" sortable="false">装修</th>
<th field="lxfs" width="100" sortable="false">联系方式</th>
<th field="context" width="100" sortable="false">内容</th>
<th field="memo" width="100" sortable="false">备注</th>
<th field="oper" width="100" sortable="true">操作人员</th>

						</tr>
					</thead>
				</table>			
			</div>
		</div>
		
		
		
			<div id="dlg" style="width:400px;
<c:if test="${cfgs['menulayout'] == 'default'}">
height:380px; 
</c:if>
<c:if test="${cfgs['menulayout'] == 'topbottom'}">
height:250px; 
</c:if>
"
				class="easyui-dialog" closed="true" modal="true" buttons="#dlg-buttons">
			<div style="padding:10px">
				<div style="float:left">
					<form id="myform" method="post" style="margin:0;padding:0">
						<table>
							<tr>
<td style="width:80px">方式</td>
<td>
<select id="op_mode" name="op_mode" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="求租">求租</option>	
		<option value="求购">求购</option>
		<option value="出租">出租</option>	
		<option value="出售">出售</option>
</select>		
	</td>
</tr>	
<tr>
<td style="width:80px">类型</td>
<td>
<select id="op_type" name="op_type" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="住宅">住宅</option>
<option value="铺面">铺面</option>
<option value="高层住宅">高层住宅</option>
<option value="多层办公">多层办公</option>
<option value="高层办公">高层办公</option>
<option value="写字楼">写字楼</option>
<option value="车库">车库</option>
<option value="厂房">厂房</option>
<option value="工厂">工厂</option>
<option value="仓库">仓库</option>
<option value="别墅">别墅</option>
<option value="住宅.铺面">住宅.铺面</option>
<option value="住宅.办公">住宅.办公</option>
<option value="住宅.仓库">住宅.仓库</option>
<option value="办公.仓库">办公.仓库</option>
<option value="地皮.空地">地皮.空地</option>
<option value="经营">经营</option>
<option value="车位">车位</option>				
</select>			
</td>
</tr>	
<tr>
<td style="width:80px">过期时间</td>
<td>
<select id="valid_time_hist" name="valid_time_hist" 
	data-options="required:true,editable:true" panelHeight="auto" class="easyui-combobox" style="width:250px;">
		<option value="3">三天</option>	
		<option value="7">一周</option>
		<option value="31">一月</option>
		<option value="91">三月</option>
		<option value="182">半年</option>	
		<option value="365">一年</option>		
</select>	
</td>
</tr>	
<tr>
<td style="width:80px">地址</td>
<td><textarea type="text" class="easyui-validatebox e-input" id="address" name="address" style="width:250px;height:50px" data-options="required:false,editable:true" ></textarea></td>
</tr>	
<tr>
<td style="width:80px">面积</td>
<td><input type="text" class="easyui-validatebox e-input" id="mj" name="mj" style="width:250px;" data-options="required:false,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">套型</td>
<td>
<select id="tx" name="tx" 
	data-options="required:false,editable:false"  panelHeight="auto" class="easyui-combobox" style="width:255px;">
<option value="1房1">1房1</option>
<option value="1房2">1房2</option>
<option value="2房1">2房1</option>
<option value="2房2">2房2</option>
<option value="3房1">3房1</option>
<option value="3房2">3房2</option>
<option value="4房1">4房1</option>
<option value="4房2">4房2</option>
<option value="5房2">5房2</option>
<option value="6房3">6房3</option>
<option value="复式">复式</option>
<option value="一格">一格</option>
<option value="二格">二格</option>
<option value="三格">三格</option>
<option value="四格">四格</option>
<option value="单间">单间</option>
<option value="套房">套房</option>
<option value="全座">全座</option>
<option value="全层">全层</option>
<option value="全套">全套</option>
</select>    

</td>
</tr>	
<tr>
<td style="width:80px">楼层</td>
<td>
<select id="lc" name="lc" 
	data-options="required:false,editable:false"  panelHeight="auto" class="easyui-combobox" style="width:255px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
</select>
</td>
</tr>	
<tr>
<td style="width:80px">价格</td>
<td><input type="text" class="easyui-validatebox e-input" id="jg" name="jg" style="width:250px;" data-options="required:false,editable:true" ></input></td>
</tr>	
<tr>
<td style="width:80px">装修</td>
<td>
<select id="zx" name="zx" 
	data-options="required:false,editable:false"  panelHeight="auto" class="easyui-combobox" style="width:255px;">
<option value="白坯">白坯</option>
<option value="装修">装修</option>
<option value="新装修">新装修</option>
<option value="简单装修">简单装修</option>
<option value="普通装修">普通装修</option>
<option value="简新装修">简新装修</option>
<option value="固定装修">固定装修</option>
<option value="配套装修">配套装修</option>
<option value="厨厕装修">厨厕装修</option>
<option value="中档装修">中档装修</option>
<option value="现代装修">现代装修</option>
<option value="时尚装修">时尚装修</option>
<option value="高级装修">高级装修</option>
<option value="豪华装修">豪华装修</option>
<option value="欧式装修">欧式装修</option>
<option value="白木装修">白木装修</option>
<option value="原木装修">原木装修</option>
<option value="公司装修">公司装修</option>
<option value="办公装修">办公装修</option>
<option value="发廊装修">发廊装修</option>
<option value="美容装修">美容装修</option>
<option value="酒楼装修">酒楼装修</option>
</select>
</td>
</tr>	
<tr>
<td style="width:80px">联系方式</td>
<td>
<textarea type="text" class="easyui-validatebox e-input" id="lxfs" name="lxfs" style="width:250px;height:50px" data-options="required:false,editable:true" ></textarea></td>
</tr>	
<tr>
<td style="width:80px">内容</td>
<td><textarea type="text" class="easyui-validatebox e-input" id="context" name="context" style="width:250px;height:50px" data-options="required:false,editable:true" ></textarea></td>
</tr>		
<tr>
<td style="width:80px">备注</td>
<td><textarea type="text" class="easyui-validatebox e-input" id="memo" name="memo" style="width:250px;height:50px" data-options="required:false,editable:true" ></textarea></td>
</tr>	
				
						</table>
					</form>
				</div>			
				<div style="clear:both"></div>
			</div>
			<div id="dlg-buttons" style="text-align:center;">
				<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="saveItem()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
			</div>
		</div>
		
		
		
		
	</body>
